<template>
  <div class="nav">
    <!-- default-active   定义默认选中 -->
    <el-menu :default-active="defaultActive" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff"
      active-text-color="#ffd04b" unique-opened router>
      <el-menu-item index="/home">
        <i class="el-icon-menu"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu v-for="item in $store.getters.getUser.menus" :key="item.id" :index="item.id.toString()">
        <template slot="title">
          <i class="item.icon"></i>
          <span>{{ item.title }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item v-for="menus in item.children" :key="menus.id" :index="menus.url">{{ menus.title }}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
export default {
  data() {
    return {
      //定义默认选中状态
      defaultActive: "/home",
    };
  },
  methods: {},
  mounted() {
    //为了解决页面刷新时    页面的显示内容    刷新显示状态
    this.defaultActive = this.$route.path;
  },
};
</script>
<style lang="less" scoped>
.el-menu {
  min-height: 92vh;
}
</style>